package me.ereach.streams;

import java.util.Arrays;
import java.util.stream.Stream;

public class Main02CreatingStream {
    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5};
        Arrays.stream(nums)
                .forEach(x -> System.out.println(x));

        System.out.println("===");
        Stream.of(1, 2, 3, 4, 5)
                .forEach(x -> System.out.println(x));

        System.out.println("===");
        Stream.generate(() -> Math.random())
                .limit(5)
                .forEach(x -> System.out.println(x));

        System.out.println("===");
        Stream.iterate(1, n -> n + 1)
                .limit(5)
                .forEach(x -> System.out.println(x));
    }
}
